<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/9/6
 * Time: 14:27
 */
namespace Admin\Controller;

class SystemController extends CommonController {
    private $user;
    private $mysite;
    public function __construct()
    {
        parent::__construct();
        $this->user=M('user');
        $this->mysite=M('mysite');
    }

    function password_change()
    {
        $this->display();


    }

    function change()
    {
        $data['email'] = $_SESSION['user']['email'];
        $data['password'] = substr(md5(I("post.old_password")), 6, -6);
        $user = $this->user->where($data)->find();
        if (!$user) {
            $this->error("密码错误");
        }

        $System=D('System');
        if(!$System->create()){
            $this->error($System->getError());
        }else{
            $System->email=$_SESSION['user']['email'];
            $System->time=time();
            $System->save();
            //dump($User->getLastSql());
            $this->success('修改成功请重新登录',U('Admin/User/logout'));
        }
    }

    function info()
    {   $mysite=$this->mysite->where('id=0')->find();
        $this->assign('mysite',$mysite);
        $this->display();
    }

    function do_info()
    {
        $this->mysite->create();
        $this->mysite->time=time();
        $this->mysite->save();
        $this->success('提交成功',U('Admin/System/info'));

    }
}